package config;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @author：xingquanxiang createTime:2020/5/1 8:37
 * description:获取配置信息
 */
public class Config {
    private static String resourceDirectory = null;
    private static String ffmpegPath = null;
    private static String headVideoPath = null;

    static {
        getConfig();
    }

    private static void getConfig(){
        InputStream inputStream = Config.class.getClassLoader().getResourceAsStream(".//config.properties");
        Properties properties = new Properties();
        try {
            properties.load(inputStream);
            if (resourceDirectory==null){
                resourceDirectory = properties.getProperty("resource.dirctory");
            }
            if (ffmpegPath==null){
                ffmpegPath = properties.getProperty("ffmpeg.path");
            }
            if (headVideoPath==null){
                headVideoPath = properties.getProperty("headVideo.path");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    public static String getResourceDirectory() {
        getConfig();
        return resourceDirectory;
    }

    public static String getFfmpegPath() {
        getConfig();
        return ffmpegPath;
    }

    public static String getHeadVideoPath() {
        getConfig();
        return headVideoPath;
    }
}
